home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr09 / fgrtodb.zip / PAF.AWK < prev    next >
Text File  |  1993-06-03  |  3KB  |  73 lines

  1. # This awk file will convert a family group record (that has been 
  2. # pre-processed with paf.sed (placing field separators with ":")
  3. # S Valentine, 7.6.89
  4.  
  5. BEGIN {  # set field separator to ":" vice the default space
  6.     FS =":" 
  7.     }
  8.  
  9. $1 ~ /FAMILY/ {  # get the mirn for the individual
  10.     mirn = $2+0 }
  11. $1 ~ /HUSBAND/ { # get the husband's name, rin
  12.     husband = $2
  13.     hrin = $3+0  # force to numeric
  14.     sex = "M" }
  15. $1 ~ /BORN/ { # get the husband's birthdate and place of birth
  16.     birthdate = $2
  17.     birthplace = $4 }
  18. $1 ~ /MARR/ { # get the husband's wedding date and place of wedding
  19.     marrdate = $2
  20.     marrplace = $4 }
  21. $1 ~ /DIED/ { # get the husband's death date and place of death
  22.     deathdate = $2
  23.     deathplace = $4 }
  24. $1 ~ /FATHER/ && sex ~ /M/ {  # get husband's parent's info
  25.     father = father_rin = mother = mother_rin = parent_mrin = ""
  26.     $3 ~ /MOTHER/ ? father = "" : father = $2
  27.     $3 ~ /MOTHER/ ? father_rin = "" : father_rin = $3+0
  28.     if ($3 ~ /MOTHER/ && $6 ~ /PARENT/) {
  29.         mother = $4
  30.         mother_rin = $5+0 }
  31.     if ($4 ~ /MOTHER/) {
  32.         mother = $5
  33.         mother_rin = $6+0 }
  34.     $7 ~ /PARENT/ ? parent_mrin = $8+0 : parent_mrin = $7+0
  35.     }
  36. $1 ~ /WIFE/ { # get the Wife's name, rin - print the husband's record
  37.     $2 == "" ? wife = "UNKNOWN" : wife = $2
  38.     wrin = $3+0   # force to numberic
  39.     sex = "F" 
  40.     printf("\"%s\",\"M\",%d,\"%s\",\"%s\",\"%s\",%d,\"%s\"",
  41.           husband, hrin, birthdate, birthplace, wife, wrin, marrdate)
  42.     printf(",\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,",
  43.           marrplace, mrin, deathdate, deathplace, father, father_rin)
  44.     printf("\"%s\",%d,%d", 
  45.           mother, mother_rin, parent_mrin) 
  46.     printf ("\n") }
  47. $1 ~ /BORN/ { # get the wife's birthdate and place of birth
  48.     birthdate = $2
  49.     birthplace = $4 }
  50. $1 ~ /DIED/ { # get the wife's death date and place of death
  51.     deathdate = $2
  52.     deathplace = $4 }
  53. $1 ~ /FATHER/ && sex ~ /F/ { # get wife's parent's info & print the record
  54.     father = father_rin = mother = mother_rin = parent_mrin = ""
  55.     $3 ~ /MOTHER/ ? father = "" : father = $2
  56.     $3 ~ /MOTHER/ ? father_rin = "" : father_rin = $3+0
  57.     if ($3 ~ /MOTHER/ && $6 ~ /PARENT/) {
  58.         mother = $4
  59.         mother_rin = $5+0 }
  60.     if ($4 ~ /MOTHER/) {
  61.         mother = $5
  62.         mother_rin = $6+0 }
  63.     $7 ~ /PARENT/ ? parent_mrin = $8+0 : parent_mrin = $7+0
  64.     printf("\"%s\",\"F\",%d,\"%s\",\"%s\",\"%s\",%d,\"%s\"",
  65.         wife, wrin, birthdate, birthplace, husband, hrin, marrdate)
  66.     printf(",\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,",
  67.         marrplace, mrin, deathdate, deathplace, father, father_rin)
  68.     printf("\"%s\",%d,%d", 
  69.         mother, mother_rin, parent_mrin) 
  70.     printf ("\n") }
  71.  
  72.